package eu.jpereira.trainings.designpatterns.structural.facade;

import eu.jpereira.trainings.designpatterns.structural.facade.model.Book;
import eu.jpereira.trainings.designpatterns.structural.facade.model.Customer;
import eu.jpereira.trainings.designpatterns.structural.facade.model.DispatchReceipt;
import eu.jpereira.trainings.designpatterns.structural.facade.model.Order;
import eu.jpereira.trainings.designpatterns.structural.facade.service.BookDBService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.CustomerDBService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.CustomerNotificationService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.OrderingService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.WharehouseService;

public class DefaultBooktoreFacade implements BookstoreFacade {

	private WharehouseService ws;
	private OrderingService os;
	private CustomerNotificationService cns;
	private BookDBService bs;
	private CustomerDBService cs;
		
	@Override
	public void placeOrder(String customerId, String isbn) 
	{
		Customer c = cs.findCustomerById(customerId);
		Book b = bs.findBookByISBN(isbn);
		Order o = os.createOrder(c, b);
		cns.notifyClient(o);
		cns.notifyClient(ws.dispatch(o));
	}
	
	public void setWharehouseService(WharehouseService ws)
	{
		this.ws = ws;
	}
	
	public void setOrderingService(OrderingService os)
	{
		this.os = os;
	}
	
	public void setCustomerNotificationService(CustomerNotificationService cns)
	{
		this.cns = cns;
	}
	
	public void setBookDBService(BookDBService bs)
	{
		this.bs = bs;
	}
	
	public void setCustomerDBService(CustomerDBService cs)
	{
		this.cs = cs;
	}

}
